$(function () {
  var lyricsData =
      [{
        title: '开不了口',
        author: '周杰伦',
        src: './sources/开不了口 - 周杰伦.mp3',
        lyrics: '[ti:开不了口]\n' +
        '[ar:周杰伦]\n' +
        '[al:范特西]\n' +
        '\n' +
        '[00:02.63]歌曲：开不了口\n' +
        '[00:04.18]歌手：周杰伦\n' +
        '[00:06.27]\n' +
        '[00:29.31]才离开没多久就开始\n' +
        '[00:32.51]担心今天的你过得好不好\n' +
        '[00:36.17]整个画面是你\n' +
        '[00:38.72]想你想的睡不著\n' +
        '[00:43.06]嘴嘟嘟那可爱的模样\n' +
        '[00:46.19]还有在你身上香香的味道\n' +
        '[00:49.76]我的快乐是你 想你想的都会笑\n' +
        '[00:56.25]没有你在 我有多难熬\n' +
        '[01:00.01](没有你在我有多难熬多烦恼)\n' +
        '[01:03.08]没有你烦 我有多烦恼\n' +
        '[01:06.89](没有你烦我有多烦恼多难熬)\n' +
        '[01:10.01]穿过云层 我试著努力向你奔跑\n' +
        '[01:16.30]爱才送到 你却已在别人怀抱\n' +
        '[01:22.45]\n' +
        '[01:23.16]就是开不了口让她知道\n' +
        '[01:28.60]我一定会呵护著你 也逗你笑\n' +
        '[01:35.86]你对我有多重要\n' +
        '[01:39.31]我后悔没让你知道\n' +
        '[01:43.26]安静的听你撒娇\n' +
        '[01:46.10]看你睡著一直到老\n' +
        '[01:50.37]就是开不了口让她知道\n' +
        '[01:56.29]就是那么简单几句 我办不到\n' +
        '[02:03.63]整颗心悬在半空\n' +
        '[02:06.65]我只能够远远看著\n' +
        '[02:10.65]这些我都做得到\n' +
        '[02:13.62]但那个人已经不是我\n' +
        '[02:18.87]\n' +
        '[02:46.31]没有你在 我有多难熬\n' +
        '[02:50.07](没有你在我有多难熬多烦恼)\n' +
        '[02:53.09]没有你烦 我有多烦恼\n' +
        '[02:56.86](没有你烦我有多烦恼多难熬)\n' +
        '[02:59.89]穿过云层 我试著努力向你奔跑\n' +
        '[03:06.32]爱才送到 你却已在别人怀抱\n' +
        '[03:12.80]\n' +
        '[03:13.18]就是开不了口让她知道\n' +
        '[03:18.48]我一定会呵护著你 也逗你笑\n' +
        '[03:25.87]你对我有多重要\n' +
        '[03:28.87]我后悔没让你知道\n' +
        '[03:32.81]安静的听你撒娇\n' +
        '[03:35.91]看你睡著一直到老\n' +
        '[03:40.27]就是开不了口让她知道\n' +
        '[03:46.14]就是那么简单几句 我办不到\n' +
        '[03:53.42]整颗心悬在半空\n' +
        '[03:56.51]我只能够远远看著\n' +
        '[04:00.38]这些我都做得到\n' +
        '[04:03.38]但那个人已经不是我\n'
      }, {
        title: '老街',
        author: '李荣浩',
        src: './sources/老街.mp3',
        lyrics: '[00:00.00] 作曲 : 李荣浩\n' +
        '[00:01.00] 作词 : 李荣浩\n' +
        '[00:15.650]\n' +
        '[00:16.990]一张褪色的照片\n' +
        '[00:20.110]好像带给我一点点怀念\n' +
        '[00:23.920]巷尾老爷爷卖的热汤面\n' +
        '[00:27.900]味道弥漫过旧旧的后院\n' +
        '[00:31.890]流浪猫睡熟在摇晃秋千\n' +
        '[00:35.820]夕阳照了一遍他咪着眼\n' +
        '[00:40.320]那张同桌寄的明信片\n' +
        '[00:44.010]安静的躺在课桌的里面\n' +
        '[00:49.050]快要过完的春天\n' +
        '[00:51.860]还有雕刻着图案的门帘\n' +
        '[00:55.930]窄窄的长长的过道两边\n' +
        '[00:59.790]老房子依然升起了炊烟\n' +
        '[01:03.780]刚刚下完了小雨的季节\n' +
        '[01:07.840]爸妈又一起走过的老街\n' +
        '[01:12.270]记不得哪年的哪一天\n' +
        '[01:15.960]很漫长又很短暂的岁月\n' +
        '[01:20.330]现在已经回不去\n' +
        '[01:24.270]早已流逝的光阴\n' +
        '[01:28.210]手里的那一张渐渐模糊不清的车票\n' +
        '[01:33.010]成了回忆的信号\n' +
        '[01:37.880]忘不掉的是什么我也不知道\n' +
        '[01:42.440]想不起当年模样\n' +
        '[01:46.290]看也看不到 去也去不了的地方\n' +
        '[01:54.010]也许那老街的腔调是属于我的忧伤\n' +
        '[02:02.300]嘴角那点微笑越来越勉强\n' +
        '[02:08.650]\n' +
        '[02:09.990]忘不掉的是什么我也不知道\n' +
        '[02:14.220]放不下熟悉片段\n' +
        '[02:18.310]回头望一眼 已经很多年的时间\n' +
        '[02:25.880]透过手指间看着天\n' +
        '[02:30.250]我又回到那老街\n' +
        '[02:34.300]靠在你们身边渐行渐远\n' +
        '[02:42.310]\n' +
        '[03:10.960]快要过完的春天\n' +
        '[03:13.960]还有雕刻着图案的门帘\n' +
        '[03:17.890]窄窄的长长的过道两边\n' +
        '[03:21.880]老房子依然升起了炊烟\n' +
        '[03:25.900]刚刚下完了小雨的季节\n' +
        '[03:29.910]爸妈又一起走过的老街\n' +
        '[03:34.260]记不得哪年的哪一天\n' +
        '[03:37.880]很漫长又很短暂的岁月\n' +
        '[03:42.310]现在已经回不去\n' +
        '[03:46.310]早已流逝的光阴\n' +
        '[03:50.050]手里的那一张渐渐模糊不清的车票\n' +
        '[03:55.010]成了回忆的信号\n' +
        '[03:59.760]忘不掉的是什么我也不知道\n' +
        '[04:04.190]想不起当年模样\n' +
        '[04:08.260]看也看不到 去也去不了的地方\n' +
        '[04:15.870]也许那老街的腔调是属于我的忧伤\n' +
        '[04:24.260]嘴角那点微笑越来越勉强\n' +
        '[04:31.880]忘不掉的是什么我也不知道\n' +
        '[04:36.240]放不下熟悉片段\n' +
        '[04:40.220]回头望一眼 已经很多年的时间\n' +
        '[04:47.840]透过手指间看着天\n' +
        '[04:52.330]我又回到那老街\n' +
        '[04:56.260]靠在你们身边渐行渐远'
      }, {
        title: '我还想她',
        author: '林俊杰',
        src: './sources/林俊杰%20-%20我还想她.mp3',
        lyrics: '[ti:我还想她]\n' +
        '[ar:林俊杰]\n' +
        '[al:]\n' +
        '[by:]\n' +
        '[00:00.40]林俊杰 - 我还想她\n' +
        '[00:20.90]歌词编辑\\刘荣华(2008 10 6)\n' +
        '[00:21.40]\n' +
        '[00:22.10]泪水将我淹没\n' +
        '[00:26.78]到底谁该难过\n' +
        '[00:30.35]究竟是谁放掉\n' +
        '[00:35.45]这段感情\n' +
        '[00:36.82]\n' +
        '[00:38.67]我才终于明白\n' +
        '[00:40.57]奔不到的承诺\n' +
        '[00:43.06]就成了枷锁\n' +
        '[00:46.69]现实中幸福\n' +
        '[00:50.78]永远缺货\n' +
        '[00:55.23]\n' +
        '[00:55.65]请告诉她\n' +
        '[00:56.19]我不爱她\n' +
        '[00:58.05]笑着难过\n' +
        '[01:00.29]自我惩罚\n' +
        '[01:02.13]\n' +
        '[01:02.62]想终止这一切挣扎\n' +
        '[01:06.48]狠了心说真心谎话\n' +
        '[01:10.05]\n' +
        '[01:10.33]别告诉她\n' +
        '[01:11.79]我还想她\n' +
        '[01:13.88]恨总比爱\n' +
        '[01:16.51]容易放下\n' +
        '[01:18.22]\n' +
        '[01:18.42]当泪水堵住了胸口\n' +
        '[01:21.90]就让沉默代替所有\n' +
        '[01:26.90]回答\n' +
        '[01:28.79]\n' +
        '[01:43.64]我才终于明白\n' +
        '[01:44.61]奔不到的承诺\n' +
        '[01:47.21]就成了枷锁\n' +
        '[01:50.68]现实中幸福\n' +
        '[01:54.45]永远缺货\n' +
        '[01:56.58]\n' +
        '[01:58.11]请告诉她\n' +
        '[01:59.83]我不爱她\n' +
        '[02:01.62]笑着难过\n' +
        '[02:03.90]自我惩罚\n' +
        '[02:05.86]\n' +
        '[02:06.64]想终止这一切挣扎\n' +
        '[02:09.75]狠了心说真心谎话\n' +
        '[02:13.58]\n' +
        '[02:14.60]别告诉她\n' +
        '[02:15.74]我还想她\n' +
        '[02:17.76]恨总比爱容易放下\n' +
        '[02:21.96]当泪水堵住了胸口\n' +
        '[02:25.88]就让沉默代替所有\n' +
        '[02:31.04]回答\n' +
        '[02:32.31]\n' +
        '[02:32.97]我不爱\n' +
        '[02:33.93]我不痛\n' +
        '[02:34.70]我不懂\n' +
        '[02:35.78]我的心早已掏空\n' +
        '[02:39.90]真心话言不由衷\n' +
        '[02:45.52]\n' +
        '[02:46.24]请告诉她\n' +
        '[02:48.06]我不爱她\n' +
        '[02:49.84]笑着难过\n' +
        '[02:52.29]自我惩罚\n' +
        '[02:53.90]\n' +
        '[02:54.33]想终止这一切挣扎\n' +
        '[02:57.82]狠了心说真心谎话\n' +
        '[03:01.77]\n' +
        '[03:02.20]别告诉她\n' +
        '[03:03.80]我还想她\n' +
        '[03:05.79]恨总比爱容易放下\n' +
        '[03:09.67]当泪水堵住了胸口\n' +
        '[03:13.85]就让沉默代替所有\n' +
        '[03:19.04]回答\n' +
        '[03:21.15]\n' +
        '[03:22.27]别告诉她\n' +
        '[03:24.13]我还想她\n' +
        '[03:26.27]就让沉默\n' +
        '[03:28.84]代替所有\n' +
        '[03:31.81]回答\n' +
        '[03:35.67]\n' +
        '[03:36.03]林俊杰 - 我还想她\n' +
        '[03:46.87]歌词编辑\\刘荣华(2008 10 6)'
      },
        {
          'title': '晴天',
          'author': '周杰伦',
          'src': './sources/周杰伦 - 晴天.mp3',
          'lyrics': '[00:00.82]晴天 \n' +
          '[00:05.82]演唱：周杰伦 \n' +
          '[00:14.82] \n' +
          '[00:29.27]故事的小黄花 \n' +
          '[00:32.30]从出生那年就飘着 \n' +
          '[00:35.83]童年的荡秋千 \n' +
          '[00:39.26]随记忆一直晃到现在 \n' +
          '[00:42.84]rui sou sou xi dou xi la \n' +
          '[00:45.72]sou la xi xi xi xi la xi la sou \n' +
          '[00:49.60]吹着前奏望着天空 \n' +
          '[00:52.92]我想起花瓣试着掉落 \n' +
          '[00:56.25]为你翘课的那一天 \n' +
          '[00:58.27]花落的那一天 \n' +
          '[00:59.79]教室的那一间 \n' +
          '[01:01.60]我怎么看不见 \n' +
          '[01:03.67]消失的下雨天 \n' +
          '[01:05.28]我好想再淋一遍 \n' +
          '[01:10.07]没想到失去的勇气我还留着 \n' +
          '[01:15.27]好想再问一遍 \n' +
          '[01:17.49]你会等待还是离开 \n' +
          '[01:24.34]刮风这天我试过握着你手 \n' +
          '[01:30.04]但偏偏雨渐渐大到我看你不见 \n' +
          '[01:38.51]还要多久我才能在你身边 \n' +
          '[01:44.92]等到放晴的那天也许我会比较好一点 \n' +
          '[01:52.43]从前从前有个人爱你很久 \n' +
          '[01:58.07]但偏偏风渐渐把距离吹得好远 \n' +
          '[02:06.40]好不容易又能再多爱一天 \n' +
          '[02:13.01]但故事的最后你好像还是说了拜拜 \n' +
          '[02:34.44]为你翘课的那一天 \n' +
          '[02:36.26]花落的那一天 \n' +
          '[02:38.02]教室的那一间 \n' +
          '[02:39.89]我怎么看不见 \n' +
          '[02:41.75]消失的下雨天 \n' +
          '[02:43.52]我好想再淋一遍 \n' +
          '[02:47.76]没想到失去的勇气我还留着 \n' +
          '[02:54.21]好想再问一遍 \n' +
          '[02:55.77]你会等待还是离开 \n' +
          '[03:02.48]刮风这天我试过握着你手 \n' +
          '[03:08.07]但偏偏雨渐渐大到我看你不见 \n' +
          '[03:16.55]还要多久我才能在你身边 \n' +
          '[03:22.95]等到放晴的那天也许我会比较好一点 \n' +
          '[03:30.42]从前从前有个人爱你很久 \n' +
          '[03:36.72]偏偏风渐渐把距离吹得好远 \n' +
          '[03:44.84]好不容易又能再多爱一天 \n' +
          '[03:51.04]但故事的最后你好像还是说了拜拜 \n' +
          '[03:59.01]刮风这天我试过握着你手 \n' +
          '[04:01.47]但偏偏雨渐渐大到我看你不见 \n' +
          '[04:05.06]还要多久我才能够在你身边 \n' +
          '[04:08.49]等到放晴那天也许我会比较好一点 \n' +
          '[04:12.62]从前从前有个人爱你很久 \n' +
          '[04:15.49]但偏偏雨渐渐把距离吹得好远 \n' +
          '[04:18.81]好不容易又能再多爱一天 \n' +
          '[04:22.60]但故事的最后你好像还是说了 '
        }],
    lyricsPlayingData = lyricsData,
    lyricsObj = {
      lyricsArr: [], // 存放每一句歌词 一句歌词一项
      lyricsJson: {},
      ti: '未知',
      ar: '佚名'
    },
    Audio = {
      isPlay: false,
      _Dom: $('#myAudio')[0],
      isMousedown: false,
      isMousedownVolume: false,
      prevVolume: 0,
      isSilence: false,
      timer: '',
      playingIndex: 0,
      playOrderStyle: [
        {style: '顺序播放', index: 0},
        {style: '单曲循环', index: 1},
        {style: '随机播放', index: 2},
        {style: '循环播放', index: 3}
      ],
      playingOrderIndex: 0,
      handleLyrics: function (lyrics) {
        var itemArr = '',
          itemTime = '',
          itemContent = '',
          musicinfoArr = []

        lyricsObj.lyricsJson = {}

        lyricsObj.lyricsArr = lyrics.split('\n')
        lyricsObj.lyricsArr.forEach(function (v) {
          itemArr = v.split(']')
          itemTime = itemArr[0]
          itemContent = itemArr[1] || ''

          itemTime = itemTime.substring(1)
          if (itemTime.indexOf('.') !== -1) {
            itemTime = Audio.handleTimeStyle(itemTime)
            lyricsObj.lyricsJson[itemTime] = itemContent
          } else {
            musicinfoArr = itemTime.split(':')
            lyricsObj[musicinfoArr[0]] = musicinfoArr[1]
          }
        })
      },
      handleTimeStyle: function (time) {
        var timeArr = [],
          minutes = 0,
          seconds = 0

        timeArr = time.split(':')

        timeArr = timeArr.map(function (v) {
          return v -= 0
        })

        minutes = timeArr[0]
        seconds = timeArr[1]
        seconds = minutes * 60 + seconds

        seconds = parseInt(seconds * 100) / 100
        return seconds
      },
      formatTime: function (time) {
        time = parseInt(time)

//        var hours = Math.floor(time / 3600)
        var minutes = Math.floor((time % 3600) / 60)
        var seconds = (time % 60)

//        hours = hours < 10 ? '0' + hours : hours
        minutes = minutes < 10 ? '0' + minutes : minutes
        seconds = seconds < 10 ? '0' + seconds : seconds

        return minutes + ':' + seconds
      },
      mountLyrics: function (index) {
        var str = '',
          songInfo = lyricsPlayingData[index].title + ' - ' + lyricsPlayingData[index].author

        for (var k in lyricsObj.lyricsJson) {
          str += '<li data-index="' + k + '">' + lyricsObj.lyricsJson[k] + '</li>'
        }
        $('.lyrics_list').html(str)

        // 歌名
        $('.music_title').text(songInfo)

        document.title = songInfo
      },
      mountMusicList: function (index) {
        var str = ''
        lyricsPlayingData.forEach(function (v) {
          str += '<li><div class="clearfix infobox"><div class="fl">' + v.title + '</div><div class="fl">' + v.author + '</div></div></li>'
        })
        $('.music_list').html(str)

        $('.music_list li').eq(index).find('.infobox').addClass('active')
      },
      handleAudioSrcChanged: function (index) {
        this._Dom.src = lyricsPlayingData[index].src
        this._Dom.load() // 改变了src之后必须调用load方法
        $(this._Dom).on('canplay', function () {
          $('.total_time').text(
            Audio.formatTime(this.duration)
          )
          $('.current_time').text(
            Audio.formatTime(0)
          )
          // 初始化音量
          $('.volume_progress .current_bar').height(this.volume * $('.volume_progress .total_bar').height())
        })

        // 正在播放的歌曲列表中高亮
        $('.music_list').find('.infobox').removeClass('active')
        $('.music_list li').eq(index).find('.infobox').addClass('active')
      },
      handleSwitch: function () {
        Audio.isPlay = !Audio.isPlay
        if (Audio.isPlay) {
          Audio._Dom.play()
          $('.switch').css({
            backgroundImage: 'url(./images/music_pause.png)'
          })
        } else {
          Audio._Dom.pause()
          $('.switch').css({
            backgroundImage: 'url(./images/music_play.png)'
          })
        }
      },
      initPage: function () {
        $('.music_list').slideToggle(0)
        this.mountMusicList(this.playingIndex)
        this.handleLyrics(lyricsPlayingData[this.playingIndex].lyrics)
        this.mountLyrics(this.playingIndex)
        this.mountMusicList(this.playingIndex)
        this.handleAudioSrcChanged(this.playingIndex)
      },
      nextSong: function () {
        var _total = lyricsPlayingData.length
        Audio.playingIndex = Audio.playingIndex == _total - 1 ? 0 : Audio.playingIndex + 1
      },
      prevSong: function () {
        var _total = lyricsPlayingData.length
        Audio.playingIndex = Audio.playingIndex == 0 ? _total - 1 : Audio.playingIndex - 1
      },
      randomSong: function () {
        var _total = lyricsPlayingData.length,
          _random = Math.floor(Math.random() * _total)
        Audio.playingIndex = _random
      },
      singleLoop: function () {
        Audio.playingIndex = Audio.playingIndex
      },
      inOrderLoop: function () {
        var _total = lyricsPlayingData.length
        Audio.playingIndex++
        if (Audio.playingIndex > _total - 1) {
          Audio.playingIndex = _total - 1
          Audio.handleSwitch()
        }
      },
      initPlayStatus: function () {
        $('.switch').css({
          backgroundImage: 'url(./images/music_pause.png)'
        })
        Audio._Dom.play()
        Audio.isPlay = true
        $('.progress_box .current_bar').width(0)
      }
    }

  $(Audio._Dom).on('timeupdate', function () {
    var currentTime = this.currentTime.toFixed(2),
      index = 0,
      percent = this.currentTime / this.duration

    // 歌词高亮
    $('.lyrics_list>li').each(function (i, v) {
      index = $(v).attr('data-index')
      if (Math.abs(index - currentTime) < 0.2) {
        $(this).addClass('current').siblings('li').removeClass('current')
        $('.lyrics_list').animate(
          {scrollTop: i * $(this).height()}, 'normal'
        )
        return
      }
    })

    // 播放进度条
    $('.progress_box .current_bar').width($('.progress_box .total_bar').width() * percent)

    // 时间进度
    $('.current_time').text(
      Audio.formatTime(this.currentTime)
    )
  })
  $(Audio._Dom).on('ended', function () {
    $('.progress_box .current_bar').width(0)
    $('.current_time').text(Audio.formatTime(0))
    // 播放下一首
    switch (Audio.playingOrderIndex) {
      case 0:  // 顺序播放
        Audio.inOrderLoop()
        break
      case 1:  // 单曲播放
        Audio.singleLoop()
        break
      case 2:  // 随机播放
        Audio.randomSong()
        break
      case 3:  // 循环播放
        Audio.nextSong()
        break
    }
    Audio.handleLyrics(lyricsPlayingData[Audio.playingIndex].lyrics)
    Audio.mountLyrics(Audio.playingIndex)
    Audio.mountMusicList(Audio.playingIndex)
    Audio.handleAudioSrcChanged(Audio.playingIndex)
    // 如果是顺序播放并且播放到最后一首的时候 不再继续播放
    if (Audio.playingOrderIndex === 0 && Audio.playingIndex === lyricsPlayingData.length - 1) {
      $('.switch').css({
        backgroundImage: 'url(./images/music_play.png)'
      })
      Audio._Dom.pause()
      Audio.isPlay = false
      $('.progress_box .current_bar').width(0)
    } else {
      Audio.initPlayStatus()
    }
  })

  $(Audio._Dom).on('volumechange', function () {
    $('.volume_box').css({backgroundImage: this.volume === 0 ? 'url(./images/voice_silence.png)' : 'url(./images/voice_light.png)'})

    $('.volume_progress .current_bar').height(this.volume * $('.volume_progress .jump_bar').height())
  })

  $('.switch').on('click', Audio.handleSwitch)
  // 音量控制条的显示和隐藏
  $('.volume_box').on('mouseover', function () {
    $('.volume_progress').toggleClass('active')
    $(this).css({backgroundImage: Audio._Dom.volume === 0 ? 'url(./images/voice_silence.png)' : 'url(./images/voice_light.png)'})

  }).on('mouseout', function () {
    $('.volume_progress').toggleClass('active')
    $(this).css({backgroundImage: 'url(./images/voice_default.png)'})
  }).on('click', function (e) {
    if (e.target !== this) {
      return
    }

    if (Audio._Dom.volume !== 0) {
      Audio.prevVolume = Audio._Dom.volume
      Audio._Dom.volume = 0
      $('.volume_progress .current_bar').animate({height: 0}, 'normal')
      $(this).css({backgroundImage: 'url(./images/voice_silence.png)'})
    } else {
      var _height = Audio.prevVolume * $('.volume_progress .total_bar').height()
      $('.volume_progress .current_bar').animate({height: _height}, 'normal')
      Audio._Dom.volume = Audio.prevVolume
    }

  })

  $('.list').on('click', function () {
    $('.music_list').slideToggle(500)
  })

  /*
  * 本地音频由于chrome浏览器的原因并不支持设置currentTime属性 所以无法进行跳跃播放
  * */
  $('.progress_box .jump_bar').on('mousedown', function (e) {
    Audio._Dom.currentTime = e.offsetX * Audio._Dom.duration / $('.progress_box .total_bar').width()

    Audio.isMousedown = true
    $('.progress_box .current_bar').width(e.offsetX)

  }).on('mousemove', function (e) {
    if (!Audio.isMousedown) {
      return
    }
    $('.progress_box .current_bar').width(e.offsetX)
  })

  // 音量跳跃
  $('.volume_progress .jump_bar').on('mousedown', function (e) {
    Audio.isMousedownVolume = true
    $('.volume_progress .current_bar').height($(this).height() - e.offsetY)
    Audio._Dom.volume = 1 - e.offsetY / $(this).height()

  }).on('mousemove', function (e) {
    if (!Audio.isMousedownVolume) {
      return
    }
    $('.volume_progress .current_bar').height($(this).height() - e.offsetY)
    Audio._Dom.volume = 1 - e.offsetY / $(this).height()
  })

  $('body').on('mouseup', function () {
    Audio.isMousedown = false
    Audio.isMousedownVolume = false
  }).on('keydown', function (e) {
    if (e.keyCode === 32) { // 按下空格键 切换暂停和播放
      Audio.handleSwitch()
    }
  })

  // 改变播放顺序
  $('.circulation_type').on('click', function () {
    if (Audio.playingOrderIndex === Audio.playOrderStyle.length - 1) {
      Audio.playingOrderIndex = 0
    } else {
      Audio.playingOrderIndex++
    }

    $(this).text(Audio.playOrderStyle[Audio.playingOrderIndex].style)
    $(this).attr('title', $(this).text())
  })

  $('.music_list').on('click', 'li', function () {
    var _index = $(this).index()
    Audio.playingIndex = _index
    Audio.handleLyrics(lyricsPlayingData[Audio.playingIndex].lyrics)
    Audio.mountLyrics(Audio.playingIndex)
    Audio.mountMusicList(Audio.playingIndex)
    Audio.handleAudioSrcChanged(Audio.playingIndex)
    Audio.initPlayStatus()
  })

  // 初始化页面
  Audio.initPage()
})